﻿@* Ui层项目 - ng-alain配置文件 *@
@using Util.Generators.Helpers
@model Util.Generators.Contexts.EntityContext
@{
    var service = new GenerateService( Model );
    Model.Output.FileNameNoExtension = "alain.config";
    Model.Output.Extension = ".ts";
    Model.Output.RelativeRootPath = $"{service.GetClientRootPath()}/src/app/config";
}
import { default as ngLang } from '@@angular/common/locales/zh';
import { EnvironmentProviders } from '@@angular/core';
import { zhCN as dateLang } from 'date-fns/locale';
import { zh_CN as zorroLang } from 'ng-zorro-antd/i18n';
import { IconDefinition } from '@@ant-design/icons-angular';
import * as AllIcons from '@@ant-design/icons-angular/icons';
import { AlainConfig } from '@@delon/util/config';
import { AlainProvideLang, provideAlain, zh_CN as delonLang } from '@@delon/theme';
import { provideReuseTabConfig } from '@@delon/abc/reuse-tab';
import { I18NService } from '@@core';

//ng-alain配置
const alainConfig: AlainConfig = {
    pageHeader: { homeI18n: 'home' },
    themeResponsive: {
        rules : {
            1: { xs: 24 },
            2: { xs: 24, sm: 12 },
            3: { xs: 24, sm: 12, md: 12, lg: 8 },
            4: { xs: 24, sm: 12, md: 12, lg: 8, xl: 8, xxl: 6 },
            5: { xs: 24, sm: 12, md: 12, lg: 8, xl: 8, xxl: 6 },
            6: { xs: 24, sm: 12, md: 12, lg: 8, xl: 6, xxl: 4 }
        }
    }
};

//默认语言配置
const defaultLang: AlainProvideLang = {
    abbr: 'zh-CN',
    ng: ngLang,
    zorro: zorroLang,
    date: dateLang,
    delon: delonLang
};

//图标配置
const antDesignIcons = AllIcons as {
    [key: string]: IconDefinition;
};
const icons: IconDefinition[] = Object.keys(antDesignIcons).map(key => antDesignIcons[key]);

/**
 * ng-alain配置提供器
 */
export const provideNgAlain = (): EnvironmentProviders[] => {
    return [
        provideReuseTabConfig(),
        provideAlain({ config: alainConfig, defaultLang, i18nClass: I18NService, icons: icons })
    ];
}